<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta charset="UTF-8">
    <title>库存统计</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 注意：项目正式环境请勿引用该地址 -->
    <script type="text/javascript" src="layui/layui.js"></script>
    <!--    <script src="layui/layui.js" charset="utf-8"></script>-->
    <link href="layui/css/layui.css" rel="stylesheet">
    <script src="layuimini/js/lay-config.js" charset="utf-8"></script>
    <script type="text/javascript">
        layui.use(['table'], function() {
            var $ = layui.jquery;
            var table = layui.table;
            var layer = layui.layer;
            table.render({
                id:'userTable',
                elem: '#userTable',
                url: 'selectInventory',
                page: true,
                count: 0,
                 toolbar: '#toolbarDemo',//显示在表头的工具条
                cellMinWidth: 80,
                height: "full-55",
                cols: [
                    [
                        {type: 'checkbox'},
                        {
                            field: 'inventoryName',
                            align: 'center',
                            title: '库存名称',
                        }, {
                        field: 'fundId',
                        title: '基金编号',
                        align: 'center',
                        sort: true

                    }, {
                        field: 'inventoryDate',
                        title: '统计日期',
                        align: 'center',
                        sort: true
                    }, {
                        field: 'inventoryOperator',
                        title: '操作员',
                        align: 'center',
                        sort: true
                    }, {
                        field: 'inventoryData',
                        title: '已统计数据',
                        align: 'center',
                        sort: true
                    },{
                        field: 'inventoryStatis',
                        title: '统计状态',
                        align: 'center'
                    }
                    ]
                ]
            });
            // 头工具栏事件
            table.on('toolbar(userTable)', function (obj) {
                if (obj.event == 'search') {

                    var checkStatus = table.checkStatus(obj.config.id); //idTest 即为基础参数 id 对应的值
                    console.log('xx=' +checkStatus.data) ;//获取选中行
                    var data = checkStatus.data;
                    if (data.length == 0) {
                        layer.msg("请至少选择一个库存进行统计",)
                    } else {
                        var ids = [];
                        for (var i = 0; i < data.length; i++) {
                            ids.push(data[i].id);
                        }
                    };
                        var dateTime = $("#dateTime").val();

                        //表格的重新加载事件
                        table.reload('userTable', {
                            method: 'post',
                            url:'selectInventory',
                            where: {
                                'dateTime': dateTime,
                                'ids': ids.join(','),
                            }
                            , page: {
                                curr: 1
                            }
                        });
                }
            });
        });

    </script>
</head>
<body style="overflow: auto; background-color: white;"
      class="layui-view-body layui-content">
<!--表格-->
<script type="text/html" id="toolbarDemo">
    <div class="layui-inline layui-show-xs-block" id="barDemo">
        <button class="layui-btn" lay-event="add" style="width: 100px;float: left;height: 30px">日期</button>
    </div>
    <div class="layui-inline layui-show-xs-block">
        <input class="layui-input" type="date" autocomplete="off" placeholder="选择日期" name="start" id="dateTime">
    </div>
    <div class="layui-inline layui-show-xs-block">
        <a class="layui-btn"  lay-filter="searchSubmit" lay-event="search">
            <i class="layui-icon">&#xe615;&nbsp;统计</i>
        </a>
    </div>
</script>
    <table id="userTable" lay-filter="userTable">  </table>

</body>


</html>